﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel;

namespace BDSimpleStatus.Models
{
    public class ServerCheckModel
    {

        public ServerCheckModel()
        {
            // Setup some defaults
            CheckHttp = true;
            CheckPing = true;
            Frequency = 5;
            Description = string.Empty;
            NextCheckDate = DateTime.Now;
            //LastCheckDate = NextCheckDate;
            Message = string.Empty;
        }

        [ReadOnly(false)]
        public int Id { get; set; }
        
        [Required(ErrorMessage="You need to provide a Name for this check")]
        public string Name { get; set; }

        [Required(ErrorMessage="The check is pretty useless witout an address to hit", AllowEmptyStrings=false)]
        public string URL { get; set; }

        [Required]
        [DisplayName("Check using ping")]
        public bool CheckPing { get; set; }
        
        [Required]
        [DisplayName("Check using http")]
        public bool CheckHttp { get; set; }

        [Required]
        [DisplayName("Minutes between checks")]
        public int Frequency { get; set; }

        [ReadOnly(false)]
        [DisplayName("Next Check at")]
        public DateTime NextCheckDate { get; set; }

        [ReadOnly(true)]
        [DisplayName("Last Time Checked")]
        public DateTime? LastCheckDate { get; set; }

        public string Description { get; set; }

        [ReadOnly(true)]
        [DisplayName("Ping check is good")]
        public bool IsPingOk { get; set; }

        [ReadOnly(true)]
        [DisplayName("Http check is good")]
        public bool IsHttpOk { get; set; }

        [DisplayName("Enabled?")]
        public bool IsEnabled { get; set; }

        [ReadOnly(true)]
        public string Message { get; set; }
    }
}